package junit;

import base.AST;
import base.Identifier;
import base.Interpreter;
import expressions.*;
import instructions.*;
import values.FantaString;
import values.Integer;

public class TestIf {

	public static void main(String args[]) {
				
		/*
		 * x = 4;
		 * y = 5;
		 * 
		 * if (y < x)
		 * 	print("not good");
		 * else
		 *  if (x == y)
		 *   print("not good");
		 *  else
		 *   print("good");
		 * 
		 */
		
		///////////////////////////////////////////
		
		// SubFibo :
		
		Identifier x = new Identifier("x");
		Identifier y = new Identifier("y");
		
		VariableAssign xVal = new VariableAssign(x, new Integer(4));
		VariableAssign yVal = new VariableAssign(y, new Integer(5));
		
		Print printgood = new Print(new FantaString("If this is printed, the test is successfull"));
		Print printnogood = new Print(new FantaString("If this is printed, the test has failed"));
		
		Less ylessx = new Less(new VariableAccess(y), new VariableAccess(x));
		Equal xequaly = new Equal(new VariableAccess(x), new VariableAccess(y));
		
		If innerIf = new If(xequaly, printnogood, printgood);
		If outerIf = new If(ylessx, printnogood, innerIf);
		
		Composition compo1 = new Composition(xVal, yVal);
		Composition compo2 = new Composition(compo1, outerIf);
		
		Interpreter.instr(compo2);
	}

}
